

function addSensorbitCod(Blockly) {




    //交通灯模块初始化
Blockly.Python.microbit_trafficlightsInit = function(block) {
    var dropdown_green = this.getFieldValue('green');
    var dropdown_yellow = this.getFieldValue('yellow');
    var dropdown_red = this.getFieldValue('red');
    Blockly.Python.definitions_['import_microbit'] = 'from microbit import *';
    Blockly.Python.definitions_['import_Waterlight'] = 'from monitor import traffic';
    Blockly.Python.definitions_['green'] = 'trafficGreenPort = ' + dropdown_green + '';
    Blockly.Python.definitions_['yellow'] = 'trafficYellowPort = ' + dropdown_yellow + '';
    Blockly.Python.definitions_['red'] = 'trafficRedPort = '+dropdown_red+'';
    return '';
  }
  
      //交通灯模块
    Blockly.Python.microbit_trafficlights = function(block) {
      var dropdown_red = this.getFieldValue('trafficlightsRed');
      var dropdown_green = this.getFieldValue('trafficlightsGreen');
      var dropdown_yellow = this.getFieldValue('trafficlightsYellow');
      var dropdown_lightTime1 = Blockly.Python.valueToCode(this, 'lightTime1', Blockly.Python.ORDER_ATOMIC);
      var code = "traffic.light(trafficGreenPort, "+ dropdown_green+")\ntraffic.light(trafficYellowPort, "+ dropdown_yellow+")\ntraffic.light(trafficRedPort, "+dropdown_red + ")\nsleep(" +dropdown_lightTime1 + ")\n";
      return code;
    }
  

    return Blockly;
}

module.exports = addSensorbitCod;

